/* CmdLineParser$Option - Decompiled by JCavaj
 * Visit http://www.bysoft.se/sureshot/jcavaj/
 */
package jargs.gnu;

public abstract class CmdLineParser$Option
{
    private String shortForm = null;
    private String longForm = null;
    private boolean wantsValue = false;
    
    public static class StringOption extends CmdLineParser.Option
    {
	public StringOption(char c, String string) {
	    super(c, string, true);
	}
	
	protected Object parseValue(String string) {
	    return string;
	}
    }
    
    public static class IntegerOption extends CmdLineParser.Option
    {
	public IntegerOption(char c, String string) {
	    super(c, string, true);
	}
	
	protected Object parseValue(String string)
	    throws CmdLineParser.IllegalOptionValueException {
	    try {
		return new Integer(string);
	    } catch (NumberFormatException numberformatexception) {
		throw new CmdLineParser.IllegalOptionValueException(this,
								    string);
	    }
	}
    }
    
    public static class BooleanOption extends CmdLineParser.Option
    {
	public BooleanOption(char c, String string) {
	    super(c, string, false);
	}
    }
    
    protected CmdLineParser$Option(char c, String string, boolean bool) {
	if (string == null)
	    throw new IllegalArgumentException("null arg forms not allowed");
	shortForm = new String(new char[] { c });
	longForm = string;
	wantsValue = bool;
    }
    
    public String shortForm() {
	return shortForm;
    }
    
    public String longForm() {
	return longForm;
    }
    
    public boolean wantsValue() {
	return wantsValue;
    }
    
    public final Object getValue(String string)
	throws CmdLineParser.IllegalOptionValueException {
	if (wantsValue) {
	    if (string == null)
		throw new CmdLineParser.IllegalOptionValueException(this, "");
	    return this.parseValue(string);
	}
	return Boolean.TRUE;
    }
    
    protected Object parseValue(String string)
	throws CmdLineParser.IllegalOptionValueException {
	return null;
    }
}
